import os
import json
from run import run

config = {
    "project_name": "ccks-ner-lab",
    "train_name": "",
    "group_name": "roformer_chinese_char_base_all-5fold",
    "architecture": "/content/drive/MyDrive/ccks2021-wws/data/output_junnyu-roformer_chinese_char_base_all_data",
    "inputs_fold": "",
    "output_path": "",
    "max_len": 128,
    "lr": 3e-5,
    "cnn": False,
    "cnn_depth": 5,
    "cnn_max_feature": 512,
    "cnn_kernel_size": 3,
    "min_feature": 64,
    "cnn_connect_layer": 5,
    "transformer_out_layer": 12,
    "epochs": 15,
    "batch_size": 16,
    "monitor": "val_loss",
    "patience": 10,
    "mode": "min",
    "steps_per_epoch": 200,
    "drop_rate": 0.1,
    "regularizer": 0,
    "freeze_layers": -1,
    "is_combain": True,
    "save_model":False,
    "k_fold_num": 5
}

prefix = "/content/drive/MyDrive/lab-result-1/groups"







for fold_id in range(5):

    config["train_name"] = f"fold_{fold_id}"

    config["inputs_fold"] = f"/content/drive/MyDrive/ccks2021-wws/lab/data/5fold/fold_{fold_id}"

    path = os.path.join(prefix, config["group_name"], config["train_name"])
    config["output_path"] = os.path.join(path, "outputs")
    config_path = os.path.join(path,"config.json")

    if not os.path.exists(path):

        os.makedirs(config["output_path"])

    json.dump(config, open(os.path.join(path, "config.json"), mode="w"))

    run(config_path)
